<%@ page language="java" import="java.util.*,edu.fzu.costlog.domain.*" pageEncoding="utf-8"%>
<%
	List<CostLog> logs = (List<CostLog>)request.getAttribute("logs");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>消费记录列表</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	
	<style>
	   .error{
	     color:red;
	   }
	</style>
	
	<script type="text/javascript">
	    function removeLog(logid,logdesc){
	    
	       if(confirm("您真的要删除编号为 " + logid + " 的消费记录: " + logdesc + " 吗?")){
	          
	          location.href = "costLogMgr?act=del&logid=" + logid;
	       }
	    }
	    
	    function updateLog(logid){
	    
	       location.href = "costLogMgr?act=getLogById&logid=" + logid;
	    }
	</script>
	
	<style> 
	  body{
	    padding:10px;
	  }
	</style>
  </head>
  
  <body>
    <h3>消费记录列表</h3>
    <%if(logs.size()> 0){%>
    <table border="1">
      <tr>
        <th>流水号</th>
        <th>消费金额</th>
        <th>消费类型</th>
        <th>消费描述</th>
        <th>消费时间</th>
        <th>操作</th>
      </tr>
      <%for(CostLog log : logs){%>
      <tr>
        <td><%=log.getLogId()%></td>
        <td><%=log.getCostAmount()%></td>
        <td><%=log.getCostType().getCategoryName()%></td>
        <td><%=log.getLogDesc()%></td>
        <td><%=log.getCostTime()%></td>
        <td>
          <button onclick="updateLog(<%=log.getLogId()%>);">修改</button>
          <button onclick="removeLog(<%=log.getLogId()%>,'<%=log.getLogDesc()%>');">删除</button>
        </td>
      </tr>
      <%} %>
    </table>
    <%}else{ %>
      <span class="error">当前没有任何消费记录!</span>
    <%} %>
  </body>
</html>
